package org.eden.web.service.impl;

import org.eden.rpc.common.entity.dao.User;
import org.eden.web.service.AbstractLoginService;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

@Service
public class PwdLoginServiceImpl extends AbstractLoginService {

    final PasswordEncoder passwordEncoder;

    public PwdLoginServiceImpl(PasswordEncoder passwordEncoder) {
        this.passwordEncoder = passwordEncoder;
        instances.put("PasswordLoginService", this);
    }

    @Override
    public boolean checkAccess(User user, String req) {
        return passwordEncoder.matches(req, user.getPassword());
    }
}
